function onLoginSubmit(){
	var username  = $("#login_user").val();
	var password  = $("#login_pass").val();
	var numGuests = $("#login_numG").val();
	var table     = $("#login_table").val();
	var button    = $("#login_button").val();

	var form = 
		"login_username=" + username +
		"&login_password=" + password +
		"&login_numGuests=" + numGuests +
 		"&login_table=" + table +
 		"&button=" + button;
		
	$.ajax({
		url: "scripts/validation.php",
		data: form,
		type: "POST",
		success: function(answer){
				if(answer == "admin")
					window.location.replace("host");
				else if(answer == "true")
					window.location.replace("client");
				else
					$("#login_error").html(answer);
			}
	});
	
	return false;	
}


function onSignUpSubmit() {
	var name 	= $("#signup_name").val();
	var surname 	= $("#signup_surname").val();
	var email 	= $("#signup_email").val();
	var username  	= $("#signup_username").val();
	var password  	= $("#signup_password").val();
	var cPassword	= $("#signup_cPassword").val();
	var button    	= $("#signup_button").val();
	
	if(password != cPassword)
		$("#signup_error").html("<span id \'signup_error\'> Passwords don't match </span>");
	else{
		var form = 
			"sign_name=" + name +
			"&sign_surname=" + surname +
			"&sign_email=" + email +
			"&sign_username=" + username +
			"&sign_password=" + password +
	 		"&button=" + button;
			
		$.ajax({
			url: "scripts/validation.php",
			data: form,
			type: "POST",
			success: function(answer){
					if(answer == "true")
						window.location.reload();
					else
						$("#signup_error").html(answer);
				}
		});
	}
	return false;	
}

function logout(){
	var button = $("#logout_button").val();
	var form =
		"button=" + button;

	$.ajax({
			url: "../scripts/validation.php",
			data: form,
			type: "POST",
			success: function(answer){
					window.location.replace('../');
				}
		});
	return  false;
}